<template>
  <div class="home-swiper">
    <swiper>
      <swiper-item v-for="item in banners">
        <!--        //动态绑定链接和图片吗-->
        <a :href="item.link">
          <img :src="item.image" alt="" @load="imgLoad">
        </a>

      </swiper-item>
    </swiper>

  </div>
</template>

<script>

import {Swiper , SwiperItem} from 'components/common/swiper'


export default {
  name: "HomeSwiper",
  props:{
    banners: {
      type: Array,
      default(){
        return []
      }
    }
  },
  components:{
    Swiper,
    SwiperItem

  },
  data(){
    return {
      isLoad: true
    }
  },
  methods:{
    imgLoad() {
      //使用isLoad来判断是否需要发送
      if (this.isLoad){
        this.$emit('swiperImgLoad')
        //改变isLoad 来记录状态（已经发送过）
        this.isLoad = false
      }
    }
  }
}
</script>

<style scoped>

</style>
